<template>
  <div class="content-block block-3">
    <div class="info-head">{{ title }}</div>
    <div class="info-content">
      <v-chart :option="chartOption" style="width:100%;height:360px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'grid-item-three',
  props: ['title'],
  computed: {
    energyIndustry () {
      return this.$store.state.energyIndustry
    },
    chartOption () {
      return {
        legend: {
          left: 'center',
        },
        grid: {
          left: '5%',
          right: '5%'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        xAxis: {
          type: 'category',
          data: this.energyIndustry.map(v => v.name),
          axisLabel: {
            interval: 0,
          },
        },
        yAxis: [
          {
            type: 'value',
            name: '万吨标准煤',
            axisLine: {
              show: true
            },
            position: 'left'
          },
          {
            type: 'value',
            name: '千克标准煤/万元',
            axisLine: {
              show: true
            },
            position: 'right'
          },
        ],
        series: [
          {
            type: 'bar',
            name: '综合能源消费量',
            yAxisIndex: 0,
            data: Array(this.energyIndustry.length).fill(1).map(() => Math.round(Math.random() * 99 + 1))
          },
          {
            type: 'bar',
            name: '产值单耗',
            yAxisIndex: 1,
            data: Array(this.energyIndustry.length).fill(1).map(() => Math.round(Math.random() * 99 + 1))
          }
        ]
      }
    }
  },
  mounted () {
    this.$store.dispatch('GET_ENERGY_INDUSTRY')
  },
}
</script>

<style scoped>

</style>
